//
//  PathStep.h
//  A* 算法
//  用于查找最短的到达路径
//
//  Created by Jacky.Chen on 13-7-1.
//
//

#import <Foundation/Foundation.h>

struct CELL_POS {
    int x;
    int y;
};
typedef struct CELL_POS CELL_POS;

@interface PathStep :  NSObject

{
	CGPoint position;
	int gScore;
	int hScore;
    int leftPosition;
    int rightPosition;
    int upPosition;
    int downPosition;
    
    int cellX;
    int cellY;
	PathStep *parent;
}
@property (nonatomic, assign) CGPoint position;
@property (nonatomic, assign) int gScore;
@property (nonatomic, assign) int hScore;

@property (nonatomic, assign) int leftPosition;
@property (nonatomic, assign) int rightPosition;
@property (nonatomic, assign) int upPosition;
@property (nonatomic, assign) int downPosition;

@property (nonatomic, assign) int cellX;
@property (nonatomic, assign) int cellY;

@property (nonatomic, assign) int currentPathIndex;
@property (nonatomic, assign) BOOL isClosed;

@property (nonatomic, assign) PathStep *parent;

+ (id)initWithPositionAndCloseArray:(CGPoint)pos closedArray:(NSMutableArray*) arrClosed;
- (void)print;
- (id)initWithPosition:(CGPoint)pos closedArray:(NSMutableArray*) arrClosed;
- (id)initWithParent:(PathStep*)fromParent targetPos:(PathStep*)target nextCellX:(int)x nextCellY:(int)y closedArray:(NSMutableArray*) arrClosed;




- (int)fScore;
//if the current path is closed or not
- (BOOL)closed;


-(id)findShortestPath:(PathStep*)current targetCell:(PathStep*)target closedArray:(NSMutableArray*) arrClosed;
@end
